package com.czk.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.czk.mapper.CourseMapper;
import com.czk.pojo.Course;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author:ChenZhangKun
 * @Date: 2021/6/21 16:05
 */
@RestController
@RequestMapping("/course")
public class CourseController {
    @Autowired
    private CourseMapper courseMapper;
    @GetMapping("/insert")
    public Course insert(){
        Course course=new Course();
        course.setCid(144L);
        course.setUserId(155L);
        course.setCstatus("love");
        course.setCname("czkk");
        courseMapper.insert(course);
        return course;
    }
    @GetMapping("/get/{id}")
    public Course getCourse(@PathVariable("id") Long id){
        QueryWrapper<Course> wrapper=new QueryWrapper<>();
        wrapper.eq("cid",id);
        Course course = courseMapper.selectOne(wrapper);
        return course;
    }
}
